//
// Created by Administrator on 2022/6/29.
//

#include "ChatPanel.h"

ChatPanel::ChatPanel( wxWindow* parent, const char* from, const char* datetime, const char* chat )
        :wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL  ){
        this->from = from;
        this->datetime = datetime;
        this->chat = chat;
    this->SetSizeHints( wxDefaultSize, wxDefaultSize );
    auto* sizer_chat = new wxBoxSizer( wxVERTICAL );
    //
    wxBoxSizer* sizer_chat_info;
    sizer_chat_info = new wxBoxSizer(wxHORIZONTAL );

    auto* static_from = new wxStaticText(this, wxID_ANY,
                                         wxString::FromUTF8( from ), wxDefaultPosition, wxDefaultSize, 0 );
    static_from->Wrap(-1 );
    static_from->SetMinSize(wxSize(100, -1 ) );

    sizer_chat_info->Add(static_from, 0, wxALL, 5 );

    auto* static_chat_datetime = new wxStaticText(this, wxID_ANY,
                             wxString::FromUTF8( datetime ), wxDefaultPosition, wxDefaultSize, 0 );
    static_chat_datetime->Wrap(-1 );
    static_chat_datetime->SetMinSize(wxSize(150, -1 ) );

    sizer_chat_info->Add(static_chat_datetime, 0, wxALL, 5 );
    //

    auto* static_chat_message = new wxStaticText( this, wxID_ANY,
            wxString::FromUTF8( chat ), wxDefaultPosition, wxDefaultSize, 0 );
    static_chat_message->Wrap( -1 );
    sizer_chat->Add( static_chat_message, 0, wxALL, 5 );

    sizer_chat->Add( sizer_chat_info , 0, wxEXPAND, 5 );

    this->SetSizer( sizer_chat );
    this->Layout();
    sizer_chat_info->Fit(this );
}

